home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Magnum One
/
Magnum One (Mid-American Digital) (Disc Manufacturing).iso
/
d12
/
cgazv5n5.arc
/
COLLECT.CPP
next >
Wrap
C/C++ Source or Header
|
1991-09-23
|
1KB
|
43 lines
//--- COLLECT.CPP ---------------------- Listing 2 -----------
// Testing the record and its container class
// See Listing 1 for copyright terms.
//------------------------------------------------------------
#include "collect.h"
class TestArray : public recordArray {
public:
TestArray() : recordArray() {}
TestArray(TestArray& rv) : recordArray(rv) {}
void show ( char * msg ) {
puts ( msg );
for ( int i = 0; i < arraySize(); i++ )
if ( null( i ) )
puts( "null element" );
else
printf( "%s: %s\n", rec( i ).Name(),
rec( i ).Description() );
}
};
main() {
TestArray a;
a.add(new record("first name", "first description"));
a.add(new record("second name", "second description"));
a.add(new record("third name", "third description"));
a.add(new record("fourth name", "fourth description"));
a.show("first show");
a.destroy(0); // leaves a null spot at location zero
a.show("a.show()"); // look to see the null spot
a.add(new record("fifth name", "fifth business"));
TestArray b(a); // make a new one to eliminate the null spots
b.show("b.show()");
}